<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<table class="display" id="example">
	<thead>
		<tr>
			<th>选择</th>
			<th>所属年份</th>
			<th>部门</th>
			<th>总分</th>
			<th>设置</th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.credits==null || #request.credits.size<=0">
			<tr class="gradeA">
				<td colspan="5">暂无数据</td>
			</tr>
		</s:if>
		<s:else>
			<s:iterator var="credit" status="sta" value="#request.credits">
				<s:if test="#sta.even">
					<tr class="gradeA">
				</s:if>
				<s:else>
					<tr class="gradeC">
				</s:else>

				<td><input type="checkbox" name="chk_creditset"
					value="${credit.id}" /></td>
				<td>${credit.year}</td>
				<td>${credit.organization.fullName}</td>
				<td><span id="GridView1_ctl04_Label1">${credit.totalScore}</span></td>
				<td><a class="button" href="#train/credit_set_manage.xhtml?creditId=${credit.id}"><span
						style="background: url(${ctx}/images/img/report_edit.png)"
						class="icon icon-ok">&nbsp;</span>设置</a></td>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>
<p>
	<%@ include file="/WEB-INF/pages/common/main_orgtab_pager_train.jsp"%>
</p>
<div class="tabs side grid_12 leading">
	<div class="clear"></div>
	<div class="grid_12">
		<div class="form-action clearfix">
			<p>
				<input type="checkbox" value="1" id="form-updates-i2"
					onchange="checkAll(this,'chk_creditset')" /><label
					for="form-updates-i2">全选</label> <a class="button"
					href="javascript:void(0)" onclick="deleteDatas('chk_creditset')"><span
					style="background: url(${ctx}/images/img/cancel.png)" class="icon">&nbsp;</span>批量删除</a>
				<a class="button"
					href="#train/credit_set_manage.xhtml?organizationId=${organizationId}"><span
					style="background: url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加</a>
			</p>
		</div>

	</div>
</div>

<div class="clear"></div>

<script type="text/javascript">	
	/**
	* 删除数据
	*/
	function deleteDatas(name) {
		var checkIds = new Array();
		$("input[type='checkbox'][name='" + name + "']").each(function() {
			if (this.checked) {
				checkIds.push(this.value);
			}
		});
		if (checkIds.length == 0) {
			return;
		}
		if (confirm("确定要删除选中的数据吗？")) {
			doDeleteDatas("${ctx}/train/creditset_delete.xhtml",checkIds.join(","));
		}
	}
	
	/**
	 * 删除指定数据集
	 * @param url
	 * @param ids
	 */
	function doDeleteDatas(url,ids) {
		$.ajax({
			type : "get",
			url : url,
			data: {"ids":ids},
			dataType : "json",
			success : function(data) {
				// load the grade list
				//currentTabOrgId
				if(typeof(currentTabOrgId) == 'number'){
					loadListContent("${ctx}${listAction}", currentTabOrgId);
				}else{
					loadListContent("${ctx}${listAction}",${organizationId});
				}
			}
		});
	}

	

	

	
</script>